using System.Collections;
using UnityEngine;
using UnityEngine.UI;
namespace Voodoo.Sauce.Tools.AccessButton
{
	public class AccessButton : MonoBehaviour
	{
		[SerializeField]
		private GameObject voodooSauceLogo;

		[SerializeField]
		private GameObject recordingLogo;

		[SerializeField]
		private BubbleButton bubbleButton;

		[SerializeField]
		private HidePanel hidePanel;

		private void Start()
		{
			AccessProcess.ButtonInstance = base.gameObject;
			bubbleButton.gameObject.SetActive(value: true);
			hidePanel.gameObject.SetActive(value: true);

			Object.DontDestroyOnLoad(base.gameObject);
		}

		private void SetRecordingAnimationEnabled(bool isRecording)
		{
			voodooSauceLogo.SetActive(!isRecording);
			recordingLogo.SetActive(isRecording);
			if (isRecording)
			{
				StartCoroutine(RecordingLogoCoroutine());
			}
			else
			{
				StopAllCoroutines();
			}
		}

		private void OnDestroy()
		{
		}

		private IEnumerator RecordingLogoCoroutine()
		{
			Image recordingImage = recordingLogo.GetComponent<Image>();
			Color color = recordingImage.color;
			color.a = 1f;
			recordingImage.color = color;
			while (true)
			{
				yield return new WaitForSeconds(0.9f);
				while (color.a > 0f)
				{
					color.a -= Time.deltaTime * 1.75f;
					recordingImage.color = color;
					yield return null;
				}
				while (color.a < 1f)
				{
					color.a += Time.deltaTime * 1.75f;
					recordingImage.color = color;
					yield return null;
				}
			}
		}
	}
}
